<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="demo">
    <h2>测试: v-for遍历数组</h2>
    <ul>
      <li v-for="(item, index) in persons" :key="item.id">
        {{item.id}}--{{item.name}}--{{item.age}}
        --<button @click="remove(index)">删除</button>
        --<button @click="update()"></button>
      </li>
    </ul>

    <h2>测试: v-for遍历对象</h2>
  </div>
  <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.12/vue.js"></script>
  <script>
    new Vue({
      el: '#demo',
      data: {
        persons: [
          {id: 1,name: 'Tom', age: 18},
          {id: 2,name: 'zs', age: 19},
          {id: 3,name: 'ls', age: 23},
          {id: 4,name: 'ww', age: 15},
          {id: 5,name: 'zl', age: 36},
        ]
      },
      methods: {
        remove(id) {
          this.persons.splice(id, 1)
        }
      }
    })
  </script>
</body>
</html>